/*
 * Copyright (c) 2020. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package cn.afterturn.easypoi.word.entity.bookmark;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class InitWordEntity {
    //只能实例化直接连接的4个Set的集合。后续的集合因为没有数据，无法采用foreach的方式来进行赋值
    public static WordEntityVO initWordEntity(String url) {
        WordEntityVO wordEntityVO = new WordEntityVO();
        wordEntityVO.setId(UUID.randomUUID().toString());
        wordEntityVO.setFilepath(url);
        String fileName="";
        if(url.contains("/")) {
            fileName = url.substring(url.lastIndexOf("/") + 1);
        }
        if(url.contains("\\")){
            fileName = url.substring(url.lastIndexOf("\\") + 1);
        }
        wordEntityVO.setFilename(fileName);
        wordEntityVO.setWordClientCommitTime(new Date());
        String fileType=url.substring(url.lastIndexOf(".")+1,url.length());
        wordEntityVO.setFilesuffixname(fileType);
        Set<ParagraphEntityVO> paragraphEntities = new HashSet<>();
        wordEntityVO.setParagraphEntityVOS(paragraphEntities);

        Set<HeaderEntityVO> headerEntities = new HashSet<>();
        /*headerEntityVOS.forEach(eachHead->{
            Set<ParagraphEntityVO> paragraphEntities1=new HashSet<>();
            setPara(paragraphEntities1);
        });*/
        wordEntityVO.setHeaderEntityVOS(headerEntities);

        Set<FootEntityVO> footEntities = new HashSet<>();
        /*footEntityVOS.forEach(eachFoot -> {
            Set<ParagraphEntityVO> paragraphEntities1 = new HashSet<>();
            setPara(paragraphEntities1);
            eachFoot.setParagraphEntityVOS(paragraphEntities1);
        });*/
        wordEntityVO.setFootEntityVOS(footEntities);

        Set<TableEntityVO> tableEntities = new HashSet<>();
        /*tableEntities.forEach(eachtable -> {
            Set<RowEntityVO> rowEntities = new HashSet<>();
            rowEntities.forEach(eachrow -> {
                Set<CellEntityVO> cellEntityVOS = new HashSet<>();
                cellEntityVOS.forEach(eachCell -> {
                    Set<ParagraphEntityVO> paragraphEntityHashSet = new HashSet<>();
                    setPara(paragraphEntityHashSet);
                    eachCell.setParagraphEntityVOS(paragraphEntityVOS);
                });
                eachrow.setCellEntityVOS(cellEntityVOS);

            });
            eachtable.setRowEntityVOS(rowEntities);
        });*/
        wordEntityVO.setTableEntityVOS(tableEntities);


        return wordEntityVO;
    }


}
